package book10ebychapters.src;
import java.util.ArrayList;
import java.util.List;
public class name {


        public static void main(String[] args) throws Exception {
            Student s1 = new Student("小明","5",21);
            Student s2 = new Student("小黄","2",23);
            Student s3 = new Student("小金","3",19);
            List<Student> list = new ArrayList<Student>();
            list.add(s1);
            list.add(s2);
            list.add(s3);

            Greet greet = new Greet("hello",50);
            PrintStudents printStudents = new PrintStudents(list);
            Greet goodbye =new Greet("goodbey",50);

            Thread t1 = new Thread(greet);
            Thread t2 = new Thread(printStudents);
            Thread t3 = new Thread(goodbye);

            t1.start();
            t2.start();
            t3.start();


        }
    }
    class Greet implements Runnable{
        private String sentence;
        private int times;

        public Greet(String sentence, int times) {
            this.sentence = sentence;
            this.times = times;
        }

        @Override
        public void run() {
            for (int i = 0; i < times; i++) {
                System.out.print(sentence);
            }
        }
    }
    class PrintStudents implements Runnable{
        private List students;

        public  PrintStudents(List students) {
            this.students = students;
        }

        @Override
        public void run() {
            students.forEach(x -> System.out.println(x));
        }
    }

